
CC = cc
TARGET = main
RM = rm -f
TOP := ..
LDIR := $(TOP)/common
CPPFLAGS := -I$(LDIR)

SOURCES = $(wildcard *.c)
OBJECTS = main.o

$(TARGET) : $(SOURCES)
	$(CC) $^ $(CPPFLAGS) -L$(LDIR)/lib -lsll -o $@

include $(SOURCES:.c=.d)
.d.c:
	set -e; rm -f $@; \
    $(CC) -MM $(CPPFLAGS) $< > $@.$$$$; \
    sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \
    rm -f $@.$$$$

.PHONY : clean
clean:
	$(RM) $(TARGET) $(OBJECTS)

